import request from "@/utils/request";

const base_url = "/admin/product";

export default {
  // 分页列表
  page: (pageNum, pageSize, queryDto) => {
    return request({
      url: `${base_url}/page`,
      method: "POST",
      data: {
        productName: queryDto.productName,
        brandName: queryDto.brandName,
        category1Id: queryDto.category1Id,
        category2Id: queryDto.category2Id,
        category3Id: queryDto.category3Id,
        status: queryDto.status,
        auditStatus: queryDto.auditStatus,
        pageNum,
        pageSize
      }
    });
  },

  // 根据ID查询商品所有信息
  getProductInfoById: id => {
    return request({
      url: `${base_url}/get/${id}`,
      method: "GET"
    });
  },

  // 新增商品
  saveProduct: data => {
    return request({
      url: `${base_url}/operate`,
      method: "POST",
      data
    });
  },

  // 删除商品
  removeProduct: id => {
    return request({
      url: `${base_url}/remove/${id}`,
      method: "POST"
    });
  },

  // 审核商品
  checkProduct: data => {
    return request({
      url: `${base_url}/check`,
      method: "POST",
      data
    });
  },

  // 商品上下架
  onSale: data => {
    return request({
      url: `${base_url}/sale`,
      method: "POST",
      data
    });
  }
};
